package com.thread.test20190330.part1.tax7;

import com.thread.test20190330.part1.tax7.java8.FunctionTaxCslculation;
import com.thread.test20190330.part1.tax7.java8.IFunctionTaxCslculation;
import com.thread.test20190330.part1.tax7.java8.SimplyFunctionTaxCslculation;
import com.thread.test20190330.part1.tax7.nojava8.SimplyTax;
import com.thread.test20190330.part1.tax7.nojava8.TaxCalculationContext;

/**
 * 策略模式
 * 对应的Thread和runnable应用解析
 *
 * 分为传统的策略模式
 * java8 函数式接口模式
 * @author Conceit
 * 2019/4/5 增加方法
 * @since 1.0.0, 2019/4/5
 */
public class TaxMain {

	public static void main(String[] args) {

		//使用传统的策略模式
		//nojava8();

		java8();
	}

	/**
	 * 这种模式只需要更换 策略以及参数
	 * 可读性高
	 * 代码相对啰嗦
	 */
	public static void nojava8(){
		TaxCalculationContext taxCalculationContext=new TaxCalculationContext();
		taxCalculationContext.setITaxCalculation(new SimplyTax());

		Integer tax=taxCalculationContext.calculation(100,10);
		System.out.println(tax);
	}

	public static void java8(){
//		new Thread(()->{
//			System.out.println(Thread.currentThread());
//		}).start();
		SimplyFunctionTaxCslculation simplyFunctionTaxCslculation=new SimplyFunctionTaxCslculation(1,2);
		FunctionTaxCslculation functionTaxCslculation1=new FunctionTaxCslculation(simplyFunctionTaxCslculation);
		FunctionTaxCslculation functionTaxCslculation2=new FunctionTaxCslculation(simplyFunctionTaxCslculation);
		FunctionTaxCslculation functionTaxCslculation3=new FunctionTaxCslculation(simplyFunctionTaxCslculation);

		Integer functionTaxCslculation1Result=functionTaxCslculation1.appley(1,2);

		System.out.println(functionTaxCslculation1Result);

		FunctionTaxCslculation tax1=new FunctionTaxCslculation(100,10);



		new FunctionTaxCslculation(100,0).appley(100,100);

		//System.out.println(IFunctionTaxCslculation.no2Tax(100,1));
	}

}
